﻿using System;

class NFaktorialK
{
    static void Main()
    {
        //Write a program that calculates N!*K! / (K-N)! for given N and K (1<N<K).

        Console.Write("N = ");
        int n = int.Parse(Console.ReadLine());
        Console.Write("K = ");
        int k = int.Parse(Console.ReadLine());

        decimal factorialN = 1;
        decimal factorialK = 1;
        decimal facorialNK =  1;

        if (k > n && n > 1)
        {
            for (int i = n; i >= 1; i--)
            {
                factorialN *= i;
            }
            for (int i = k; i >= 1; i--)
            {
                factorialK *= i;
            }
            for (int i = (k-n); i >= 1; i--)
            {
                facorialNK *= i;
            }

            Console.WriteLine("N! = " + factorialN);
            Console.WriteLine("K! = " + factorialK);
            Console.WriteLine("(K-N)! = " + facorialNK);
            decimal result = (factorialN * factorialK) / facorialNK;
            Console.WriteLine("N!*K! / (K-N)! = {0}", result);
        }
    }
}


